package com.mdd.admin.controller.client;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.IClientCrmProjetDetailTypeService;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.ClientCrmProjetDetailTypeCreateValidate;
import com.mdd.admin.validate.ClientCrmProjetDetailTypeUpdateValidate;
import com.mdd.admin.validate.ClientCrmProjetDetailTypeSearchValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.vo.ClientCrmProjetDetailTypeListedVo;
import com.mdd.admin.vo.ClientCrmProjetDetailTypeDetailVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/DetailType")
@Api(tags = "项目政策关联申报条件管理")
public class ClientCrmProjetDetailTypeController {

    @Resource
    IClientCrmProjetDetailTypeService iClientCrmProjetDetailTypeService;

    @GetMapping("/list")
    @ApiOperation(value="项目政策关联申报条件列表")
    public AjaxResult<PageResult<ClientCrmProjetDetailTypeListedVo>> list(@Validated PageValidate pageValidate,
                                                     @Validated ClientCrmProjetDetailTypeSearchValidate searchValidate) {
        PageResult<ClientCrmProjetDetailTypeListedVo> list = iClientCrmProjetDetailTypeService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="项目政策关联申报条件详情")
    public AjaxResult<ClientCrmProjetDetailTypeDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        ClientCrmProjetDetailTypeDetailVo detail = iClientCrmProjetDetailTypeService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "项目政策关联申报条件新增")
    @PostMapping("/add")
    @ApiOperation(value="项目政策关联申报条件新增")
    public AjaxResult<Object> add(@Validated @RequestBody ClientCrmProjetDetailTypeCreateValidate createValidate) {
        iClientCrmProjetDetailTypeService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "项目政策关联申报条件批量新增")
    @PostMapping("/addList")
    @ApiOperation(value="项目政策关联申报条件批量新增")
    public AjaxResult<Object> addList(@Validated @RequestBody ClientCrmProjetDetailTypeCreateValidate createValidate) {
        iClientCrmProjetDetailTypeService.addList(createValidate);
        return AjaxResult.success();
    }


    @Log(title = "项目政策关联申报条件编辑")
    @PostMapping("/edit")
    @ApiOperation(value="项目政策关联申报条件编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody ClientCrmProjetDetailTypeUpdateValidate updateValidate) {
        iClientCrmProjetDetailTypeService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "项目政策关联申报条件删除")
    @PostMapping("/del")
    @ApiOperation(value="项目政策关联申报条件删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iClientCrmProjetDetailTypeService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
